﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityBinder.Interface;

namespace EntityBinder.Xml
{
	class XmlElementWriter : IElementWriter
	{
		private System.Xml.XmlWriter m_writer = null;

		public XmlElementWriter(System.Xml.XmlWriter _writer)
		{
			if(_writer == null)
			{
				throw new EntityBinderException("XmlElementWriter", "<ctor>", "Can not create an XmlElementWriter without any Writer");
			}
			m_writer = _writer;
		}

		public void WriteObjectStart(string _containerName)
		{
			WriteElementStart(_containerName);
		}

		public void WriteObjectEnd()
		{
			WriteElementEnd();
		}

		public void WriteArrayStart(string _arrayName)
		{
			//WriteElementStart(_arrayName);
		}

		public void WriteArrayEnd()
		{
			//WriteElementEnd();
		}

		public void WriteElementStart(string _elementName)
		{
			m_writer.WriteStartElement(_elementName);
		}

		public void WriteElementEnd()
		{
			m_writer.WriteEndElement();
		}

		public void WriteElementValue(string _value)
		{
			m_writer.WriteValue(_value);
		}
	}
}
